package com.jingtai.platform.controller.shop;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.jingtai.core.entity.BaseEntity;
import com.jingtai.core.entity.shop.GoodsSpecificationsValue;
import com.jingtai.platform.service.shop.GoodsSpecificationsValueService;
import com.jingtai.platform.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.jingtai.validate.swagger.CApiParam;

import java.util.List;

/**
 * 商品规格属性值表
 *
 * @author sunlaiqian
 * @date 2020-12-09 15:39:05
 */
@RestController
@RequestMapping("/platform/goodsspecificationsvalue")
@Api(tags = "商品规格属性值表")
public class GoodsSpecificationsValueController{

    @Autowired
    private GoodsSpecificationsValueService goodsSpecificationsValueService;


    @ApiOperation("商品规格属性值表列表查询")
    @GetMapping("/list")
    public ResultUtil aopGoodsSpecificationsValueList(@CApiParam(name = "page",value = "页数",required = true,cNotEmpty = true,cIntMin = 1) @RequestParam("page") Integer page,
                              @CApiParam(name = "limit",value = "每页个数",required = true,cNotEmpty = true) @RequestParam("limit") Integer limit,
                              @CApiParam(name = "conditions",value = "查询条件",required = false) @RequestParam("conditions") String conditions){
        return goodsSpecificationsValueService.GoodsSpecificationsValuelist(page, limit, conditions);
    }


    @ApiOperation("根据ID查询goodsSpecificationsValue实体")
    @GetMapping("/getGoodsSpecificationsValueById")
    public ResultUtil GetGoodsSpecificationsValueById(@CApiParam(name = "id",value = "goodsSpecificationsValue实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return goodsSpecificationsValueService.getGoodsSpecificationsValueById(id);
    }


    @ApiOperation("新增goodsSpecificationsValue实体")
    @PostMapping("/add")
    @ApiOperationSupport(ignoreParameters = {"goodsSpecificationsValue.id","goodsSpecificationsValue.createTime","goodsSpecificationsValue.updateTime","goodsSpecificationsValue.deleteFlag"})
    @Transactional(rollbackFor=Exception.class)
    public ResultUtil aopAddGoodsSpecificationsValue(@RequestBody @Validated({BaseEntity.Create.class}) List<GoodsSpecificationsValue> goodsSpecificationsValue){
        return goodsSpecificationsValueService.addGoodsSpecificationsValue(goodsSpecificationsValue);
    }

    @ApiOperation("编辑goodsSpecificationsValue实体")
    @PostMapping("/edit")
    @ApiOperationSupport(ignoreParameters = {"goodsSpecificationsValue.createTime","goodsSpecificationsValue.updateTime","goodsSpecificationsValue.deleteFlag"})
    @Transactional(rollbackFor=Exception.class)
    public ResultUtil aopEditGoodsSpecificationsValue(@RequestBody @Validated({BaseEntity.Update.class}) List<GoodsSpecificationsValue> goodsSpecificationsValue){
        return goodsSpecificationsValueService.editGoodsSpecificationsValue(goodsSpecificationsValue);
    }

    @ApiOperation("根据ID删除goodsSpecificationsValue实体")
    @GetMapping("/delGoodsSpecificationsValueById")
    public ResultUtil aopDelGoodsSpecificationsValueById(@CApiParam(name = "id",value = "goodsSpecificationsValue实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return goodsSpecificationsValueService.delGoodsSpecificationsValueById(id);
    }

    @ApiOperation("根据规格ID查询goodsSpecificationsValue实体")
    @GetMapping("/selectGoodsSpecificationsValueBySpecificationsId")
    public ResultUtil aopSelectGoodsSpecificationsValueBySpecificationsId(@CApiParam(name = "id",value = "goodsSpecifications实体ID",required = true,cNotEmpty = true) @RequestParam("id") Long id){
        return goodsSpecificationsValueService.selectGoodsSpecificationsValueBySpecificationsId(id);
    }

}






